import React, { FC, useReducer, createContext } from "react";
import TableList from "./List";
import TableForm from "./Form";
import initialState from "./store";
import listReducer from "./action";
import { actionType } from "./action";

export const reeducerContext = createContext({
  state: initialState,
  dispatch: (action: actionType) => {},
});

const TableReducer: FC = () => {
  const [state, dispatch] = useReducer(listReducer, initialState);
  return (
    <>
      <div>表格简单的增加减少通过reducer和context</div>
      <reeducerContext.Provider value={{ state, dispatch }}>
        <TableList></TableList>
        <TableForm></TableForm>
      </reeducerContext.Provider>
    </>
  );
};

export default TableReducer;
